package com.hnkywl.sts.dao.organ;

import com.hnkywl.sts.entity.organ.LjLs;
import net.ruixin.orm.hibernate.Page;
import net.ruixin.orm.hibernate.SimpleHibernateTemplate;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;


/**
 * 说明：
 * 包:        com.hnkywl.sts.dao.sys
 * 类描述:    岗位dao类
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Repository
public class LjLsDao extends SimpleHibernateTemplate<LjLs, Long> {

    public Page<LjLs> findLjLsList(Long jyjgId,Integer lx,int pageNo, int pageSize) {
        Page<LjLs> page = new Page<LjLs>();
        page.setAutoCount(true);
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);
        page.setOrder("desc");
        page.setOrderBy("lastUpdated");
        List<String> conditions = new ArrayList<String>();
        List<Object> params = new ArrayList<Object>();
        if (jyjgId != null) {
            conditions.add(" lj.jyjg.id=? ");
            params.add(jyjgId);
        }
        if (lx != null) {
            conditions.add(" lx = ? ");
            params.add(lx);
        }
        String hql = "from LjLs " + (conditions.isEmpty() ? "" : " where " + StringUtils.join(conditions.toArray(), " and "));
        return this.find(page, hql, params.toArray());
    }

}
